﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LCTNote.Models.ViewModels;
using LCTNote.Models.DataModels;

namespace LCTNote.Services
{
    class NguoiDungService : Service
    {
        public static string layMatKhauTheoTaiKhoan(string taiKhoan)
        {
            string matKhau;

            matKhau = executeScalar<string>
                (
                    "Note_layMatKhauNguoiDungTheoTaiKhoan",
                    new object[]
                    {
                        taiKhoan
                    }
                );

            return matKhau;
        }

        public static bool themNguoiDung(NguoiDungDataModel nguoiDung)
        {
            return executeNonQuery
            (
                "Note_themNguoiDung",
                new object[]
                {
                    nguoiDung.tenDangNhap,
                    nguoiDung.matKhau,
                    nguoiDung.tenHienThi,
                    nguoiDung.gioiTinh,
                    nguoiDung.ngaySinh,
                    nguoiDung.diaChi,
                    nguoiDung.soDienThoai
                }
            );
        }

        public static NguoiDungViewModel layNguoiDungTheoMa(int ma)
        {
            return executeDataReader<NguoiDungViewModel>
                (
                    "Note_layNguoiDungTheoMa",
                    new object[]
                    {
                        ma
                    }
                );
        }

        public static NguoiDungViewModel layNguoiDungTheoTenDangNhap(string tenDangNhap)
        {
            return executeDataReader<NguoiDungViewModel>
                (
                    "Note_layNguoiDungTheoTenDangNhap",
                    new object[]
                    {
                        tenDangNhap
                    }
                );
        }
    }
}
